<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>发送 POST 请求</title>
    <style>
       div{
        width: 200px;
        height: 200px;
        border: solid 1px #999;
       }
    </style>
</head>
<body>
    <div></div>
    <script>
        //获取 div
        let div = document.querySelector('div');
        //绑定事件
        div.onmouseover = function(){
            //发送请求
            let xhr = new XMLHttpRequest();
            //设置请求行
            xhr.open('put', 'http://127.0.0.1/server');
            //请求头
            xhr.setRequestHeader('xxx', 100);
            xhr.send();
            //
            xhr.onload = function(){
                //响应体结果处理
                // console.log(xhr.response);
                // div.innerHTML = xhr.response;
                console.log(xhr.getAllResponseHeaders());
            }
        }
    </script>
</body>
</html>